/* 
 * @(#)ClientTest.java    Created on 2011-4-15
 * Copyright (c) 2011 ZDSoft Networks, Inc. All rights reserved.
 * $Id$
 */
package bjxg.test.msgClient;

import net.zdsoft.message.client.MessageClient;
import net.zdsoft.message.client.MessageException;
import net.zdsoft.message.client.MessageHandler;

/**
 * @author chengcy
 * @version $Revision: 1.0 $, $Date: 2011-4-15 ����02:55:37 $
 */
public class ClientTest2 implements Runnable, MessageHandler {
    public MessageClient messageClient;

    /**
     * @param args
     */
    public static void main(String[] args) {
        ClientTest2 client = new ClientTest2();
        client.start();
        String msg = "在";

        for (int n = 1; n <= 1; n++) {
            client.messageClient.sendMessage("etoh2_web_mms", msg);
        }
        try {
            Thread.sleep(10000);
        }
        catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        client.messageClient.close();
    }

    public void start() {
        try {
            messageClient = new MessageClient(this);
            messageClient.connect("192.168.1.178", 5500, "测试", "测试");
        }
        catch (MessageException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    @Override
    public void kickedOutByServer() {
        // TODO Auto-generated method stub

    }

    @Override
    public void messageReceived(byte[] arg0, String arg1, String arg2) {
        System.out.println(arg2);
    }

    @Override
    public void messageSubmitted(byte[] arg0) {
        // TODO Auto-generated method stub

    }

    @Override
    public void run() {
        // TODO Auto-generated method stub
        for (;;) {
            try {
                Thread.sleep(10000);
            }
            catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }

}
